import router from '@system.router';
import CourseApi from '../../api/courseApi.js'

export default {
    data: {
        baseImageUrl: '',
        id: 0,
        showPanelImage: 0,
        tab: 0,
        course: {
            /*"cover": "kecheng2.jpg",
            "teacher": "陆超",
            "phone": "13437124333",
            "name": "Spring Boot 编程思想",
            "classHour": "64",
            "id": 2,
            "introduction": "《Spring Boot 编程思想（核心篇）》是《Spring Boot 编程思想》的核心篇，开篇总览Spring Boot核心特性，接着讨论自动装配（Auto-Configuration）与SpringApplication。全书的讨论以Spring Boot为中心，议题发散至Spring技术栈、JSR及Java。希望透过全局的视角，帮助读者了解Spring Boot变迁的历程；经过多方的比较，帮助读者理解Spring Boot特性的原理；整合标准的规范，帮助读者掌握Spring Boot设计的哲学。",
            "email": "luchao@isoftstone.com"*/
        },
        catalogues: [],
    },
    onShow() {
        this.baseImageUrl = this.$app.$def.globalData.baseImageUrl;
        this.id = router.getParams().id;
        CourseApi.getCourse(this.id, (data) => {
            this.course = data;
        });
        CourseApi.getCatalogues(this.id, (data) => {
            this.catalogues = data;
        });
    },
    goBack() {
        router.back();
    },
    showPanel() {
        this.$element('course_introduction').show();
        this.showPanelImage = 1;
    },
    changeMode(param) {
        if (param.mode == 'mini') {
            this.$element('course_introduction').close();
            this.showPanelImage = 0;
        }
    },
    changeTabs(index) {
        this.tab = index;
    },
    studyChapter(courseName, path) {
        router.push({
            uri: 'pages/courseStudy/courseStudy',
            params: {
                courseName,
                materialPath: path
            }
        })
    },
}
